﻿#region Using directives

using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;

using ITViet.Domains;
using ITViet.Data;

#endregion

namespace ITViet.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="NewsProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract partial class NewsProviderBaseCore : EntityProviderBase<ITViet.Domains.News, ITViet.Domains.NewsKey>
	{		
		#region Get from Many To Many Relationship Functions
		#endregion	
		
		#region Delete Methods

		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to delete.</param>
		/// <returns>Returns true if operation suceeded.</returns>
		public override bool Delete(TransactionManager transactionManager, ITViet.Domains.NewsKey key)
		{
			return Delete(transactionManager, key.Id);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="_id">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public bool Delete(System.Int32 _id)
		{
			return Delete(null, _id);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_id">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public abstract bool Delete(TransactionManager transactionManager, System.Int32 _id);		
		
		#endregion Delete Methods
		
		#region Get By Foreign Key Functions
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblNews_tblNewsCategory key.
		///		FK_tblNews_tblNewsCategory Description: 
		/// </summary>
		/// <param name="_categoryId"></param>
		/// <returns>Returns a typed collection of ITViet.Domains.News objects.</returns>
		public TList<News> GetByCategoryId(System.Int32 _categoryId)
		{
			int count = -1;
			return GetByCategoryId(_categoryId, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblNews_tblNewsCategory key.
		///		FK_tblNews_tblNewsCategory Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_categoryId"></param>
		/// <returns>Returns a typed collection of ITViet.Domains.News objects.</returns>
		/// <remarks></remarks>
		public TList<News> GetByCategoryId(TransactionManager transactionManager, System.Int32 _categoryId)
		{
			int count = -1;
			return GetByCategoryId(transactionManager, _categoryId, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblNews_tblNewsCategory key.
		///		FK_tblNews_tblNewsCategory Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_categoryId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of ITViet.Domains.News objects.</returns>
		public TList<News> GetByCategoryId(TransactionManager transactionManager, System.Int32 _categoryId, int start, int pageLength)
		{
			int count = -1;
			return GetByCategoryId(transactionManager, _categoryId, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblNews_tblNewsCategory key.
		///		fkTblNewsTblNewsCategory Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_categoryId"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of ITViet.Domains.News objects.</returns>
		public TList<News> GetByCategoryId(System.Int32 _categoryId, int start, int pageLength)
		{
			int count =  -1;
			return GetByCategoryId(null, _categoryId, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblNews_tblNewsCategory key.
		///		fkTblNewsTblNewsCategory Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_categoryId"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of ITViet.Domains.News objects.</returns>
		public TList<News> GetByCategoryId(System.Int32 _categoryId, int start, int pageLength,out int count)
		{
			return GetByCategoryId(null, _categoryId, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tblNews_tblNewsCategory key.
		///		FK_tblNews_tblNewsCategory Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_categoryId"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of ITViet.Domains.News objects.</returns>
		public abstract TList<News> GetByCategoryId(TransactionManager transactionManager, System.Int32 _categoryId, int start, int pageLength, out int count);
		
		#endregion

		#region Get By Index Functions
		
		/// <summary>
		/// 	Gets a row from the DataSource based on its primary key.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to retrieve.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <returns>Returns an instance of the Entity class.</returns>
		public override ITViet.Domains.News Get(TransactionManager transactionManager, ITViet.Domains.NewsKey key, int start, int pageLength)
		{
			return GetById(transactionManager, key.Id, start, pageLength);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key PK_tblNews index.
		/// </summary>
		/// <param name="_id"></param>
		/// <returns>Returns an instance of the <see cref="ITViet.Domains.News"/> class.</returns>
		public ITViet.Domains.News GetById(System.Int32 _id)
		{
			int count = -1;
			return GetById(null,_id, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tblNews index.
		/// </summary>
		/// <param name="_id"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="ITViet.Domains.News"/> class.</returns>
		public ITViet.Domains.News GetById(System.Int32 _id, int start, int pageLength)
		{
			int count = -1;
			return GetById(null, _id, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tblNews index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_id"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="ITViet.Domains.News"/> class.</returns>
		public ITViet.Domains.News GetById(TransactionManager transactionManager, System.Int32 _id)
		{
			int count = -1;
			return GetById(transactionManager, _id, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tblNews index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_id"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="ITViet.Domains.News"/> class.</returns>
		public ITViet.Domains.News GetById(TransactionManager transactionManager, System.Int32 _id, int start, int pageLength)
		{
			int count = -1;
			return GetById(transactionManager, _id, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tblNews index.
		/// </summary>
		/// <param name="_id"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="ITViet.Domains.News"/> class.</returns>
		public ITViet.Domains.News GetById(System.Int32 _id, int start, int pageLength, out int count)
		{
			return GetById(null, _id, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tblNews index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_id"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="ITViet.Domains.News"/> class.</returns>
		public abstract ITViet.Domains.News GetById(TransactionManager transactionManager, System.Int32 _id, int start, int pageLength, out int count);
						
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key UQ_tblNews_Code index.
		/// </summary>
		/// <param name="_code"></param>
		/// <returns>Returns an instance of the <see cref="ITViet.Domains.News"/> class.</returns>
		public ITViet.Domains.News GetByCode(System.String _code)
		{
			int count = -1;
			return GetByCode(null,_code, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the UQ_tblNews_Code index.
		/// </summary>
		/// <param name="_code"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="ITViet.Domains.News"/> class.</returns>
		public ITViet.Domains.News GetByCode(System.String _code, int start, int pageLength)
		{
			int count = -1;
			return GetByCode(null, _code, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the UQ_tblNews_Code index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_code"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="ITViet.Domains.News"/> class.</returns>
		public ITViet.Domains.News GetByCode(TransactionManager transactionManager, System.String _code)
		{
			int count = -1;
			return GetByCode(transactionManager, _code, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the UQ_tblNews_Code index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_code"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="ITViet.Domains.News"/> class.</returns>
		public ITViet.Domains.News GetByCode(TransactionManager transactionManager, System.String _code, int start, int pageLength)
		{
			int count = -1;
			return GetByCode(transactionManager, _code, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the UQ_tblNews_Code index.
		/// </summary>
		/// <param name="_code"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="ITViet.Domains.News"/> class.</returns>
		public ITViet.Domains.News GetByCode(System.String _code, int start, int pageLength, out int count)
		{
			return GetByCode(null, _code, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the UQ_tblNews_Code index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_code"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="ITViet.Domains.News"/> class.</returns>
		public abstract ITViet.Domains.News GetByCode(TransactionManager transactionManager, System.String _code, int start, int pageLength, out int count);
						
		#endregion "Get By Index Functions"
	
		#region Custom Methods
		
		
		#region _tblNews_GetOtherNews 
		
		/// <summary>
		///	This method wrap the '_tblNews_GetOtherNews' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="currentNewsId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="count"> A <c>System.Int32?</c> instance.</param>
		/// <param name="newsType"> A <c>System.String</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="TList&lt;News&gt;"/> instance.</returns>
		public TList<News> GetOtherNews(System.Int32? categoryId, System.Int32? languageId, System.Int32? currentNewsId, System.Int32? count, System.String newsType)
		{
			return GetOtherNews(null, 0, int.MaxValue , categoryId, languageId, currentNewsId, count, newsType);
		}
		
		/// <summary>
		///	This method wrap the '_tblNews_GetOtherNews' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="currentNewsId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="count"> A <c>System.Int32?</c> instance.</param>
		/// <param name="newsType"> A <c>System.String</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="TList&lt;News&gt;"/> instance.</returns>
		public TList<News> GetOtherNews(int start, int pageLength, System.Int32? categoryId, System.Int32? languageId, System.Int32? currentNewsId, System.Int32? count, System.String newsType)
		{
			return GetOtherNews(null, start, pageLength , categoryId, languageId, currentNewsId, count, newsType);
		}
				
		/// <summary>
		///	This method wrap the '_tblNews_GetOtherNews' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="currentNewsId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="count"> A <c>System.Int32?</c> instance.</param>
		/// <param name="newsType"> A <c>System.String</c> instance.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="TList&lt;News&gt;"/> instance.</returns>
		public TList<News> GetOtherNews(TransactionManager transactionManager, System.Int32? categoryId, System.Int32? languageId, System.Int32? currentNewsId, System.Int32? count, System.String newsType)
		{
			return GetOtherNews(transactionManager, 0, int.MaxValue , categoryId, languageId, currentNewsId, count, newsType);
		}
		
		/// <summary>
		///	This method wrap the '_tblNews_GetOtherNews' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="currentNewsId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="count"> A <c>System.Int32?</c> instance.</param>
		/// <param name="newsType"> A <c>System.String</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="TList&lt;News&gt;"/> instance.</returns>
		public abstract TList<News> GetOtherNews(TransactionManager transactionManager, int start, int pageLength , System.Int32? categoryId, System.Int32? languageId, System.Int32? currentNewsId, System.Int32? count, System.String newsType);
		
		#endregion
		
		#region _tblNews_GetNewsCategoryWithoutLocale 
		
		/// <summary>
		///	This method wrap the '_tblNews_GetNewsCategoryWithoutLocale' stored procedure. 
		/// </summary>
		/// <param name="newsType"> A <c>System.String</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetNewsCategoryWithoutLocale(System.String newsType)
		{
			return GetNewsCategoryWithoutLocale(null, 0, int.MaxValue , newsType);
		}
		
		/// <summary>
		///	This method wrap the '_tblNews_GetNewsCategoryWithoutLocale' stored procedure. 
		/// </summary>
		/// <param name="newsType"> A <c>System.String</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetNewsCategoryWithoutLocale(int start, int pageLength, System.String newsType)
		{
			return GetNewsCategoryWithoutLocale(null, start, pageLength , newsType);
		}
				
		/// <summary>
		///	This method wrap the '_tblNews_GetNewsCategoryWithoutLocale' stored procedure. 
		/// </summary>
		/// <param name="newsType"> A <c>System.String</c> instance.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetNewsCategoryWithoutLocale(TransactionManager transactionManager, System.String newsType)
		{
			return GetNewsCategoryWithoutLocale(transactionManager, 0, int.MaxValue , newsType);
		}
		
		/// <summary>
		///	This method wrap the '_tblNews_GetNewsCategoryWithoutLocale' stored procedure. 
		/// </summary>
		/// <param name="newsType"> A <c>System.String</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public abstract DataSet GetNewsCategoryWithoutLocale(TransactionManager transactionManager, int start, int pageLength , System.String newsType);
		
		#endregion
		
		#region _tblNews_GetByHomeSearch 
		
		/// <summary>
		///	This method wrap the '_tblNews_GetByHomeSearch' stored procedure. 
		/// </summary>
		/// <param name="searchKey"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="categoryId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="hotNews"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="newsType"> A <c>System.String</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="TList&lt;News&gt;"/> instance.</returns>
		public TList<News> GetByHomeSearch(System.String searchKey, System.Int32? languageId, System.Int32? categoryId, System.Boolean? hotNews, System.String newsType)
		{
			return GetByHomeSearch(null, 0, int.MaxValue , searchKey, languageId, categoryId, hotNews, newsType);
		}
		
		/// <summary>
		///	This method wrap the '_tblNews_GetByHomeSearch' stored procedure. 
		/// </summary>
		/// <param name="searchKey"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="categoryId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="hotNews"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="newsType"> A <c>System.String</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="TList&lt;News&gt;"/> instance.</returns>
		public TList<News> GetByHomeSearch(int start, int pageLength, System.String searchKey, System.Int32? languageId, System.Int32? categoryId, System.Boolean? hotNews, System.String newsType)
		{
			return GetByHomeSearch(null, start, pageLength , searchKey, languageId, categoryId, hotNews, newsType);
		}
				
		/// <summary>
		///	This method wrap the '_tblNews_GetByHomeSearch' stored procedure. 
		/// </summary>
		/// <param name="searchKey"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="categoryId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="hotNews"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="newsType"> A <c>System.String</c> instance.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="TList&lt;News&gt;"/> instance.</returns>
		public TList<News> GetByHomeSearch(TransactionManager transactionManager, System.String searchKey, System.Int32? languageId, System.Int32? categoryId, System.Boolean? hotNews, System.String newsType)
		{
			return GetByHomeSearch(transactionManager, 0, int.MaxValue , searchKey, languageId, categoryId, hotNews, newsType);
		}
		
		/// <summary>
		///	This method wrap the '_tblNews_GetByHomeSearch' stored procedure. 
		/// </summary>
		/// <param name="searchKey"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="categoryId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="hotNews"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="newsType"> A <c>System.String</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="TList&lt;News&gt;"/> instance.</returns>
		public abstract TList<News> GetByHomeSearch(TransactionManager transactionManager, int start, int pageLength , System.String searchKey, System.Int32? languageId, System.Int32? categoryId, System.Boolean? hotNews, System.String newsType);
		
		#endregion
		
		#region _tblNews_GetAllLanguages 
		
		/// <summary>
		///	This method wrap the '_tblNews_GetAllLanguages' stored procedure. 
		/// </summary>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetAllLanguages()
		{
			return GetAllLanguages(null, 0, int.MaxValue );
		}
		
		/// <summary>
		///	This method wrap the '_tblNews_GetAllLanguages' stored procedure. 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetAllLanguages(int start, int pageLength)
		{
			return GetAllLanguages(null, start, pageLength );
		}
				
		/// <summary>
		///	This method wrap the '_tblNews_GetAllLanguages' stored procedure. 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetAllLanguages(TransactionManager transactionManager)
		{
			return GetAllLanguages(transactionManager, 0, int.MaxValue );
		}
		
		/// <summary>
		///	This method wrap the '_tblNews_GetAllLanguages' stored procedure. 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public abstract DataSet GetAllLanguages(TransactionManager transactionManager, int start, int pageLength );
		
		#endregion
		
		#region _tblNews_GetAllNewsCategory 
		
		/// <summary>
		///	This method wrap the '_tblNews_GetAllNewsCategory' stored procedure. 
		/// </summary>
		/// <param name="newsType"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="currentLanguageId"> A <c>System.Int32?</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetAllNewsCategory(System.String newsType, System.Int32? languageId, System.Int32? currentLanguageId)
		{
			return GetAllNewsCategory(null, 0, int.MaxValue , newsType, languageId, currentLanguageId);
		}
		
		/// <summary>
		///	This method wrap the '_tblNews_GetAllNewsCategory' stored procedure. 
		/// </summary>
		/// <param name="newsType"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="currentLanguageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetAllNewsCategory(int start, int pageLength, System.String newsType, System.Int32? languageId, System.Int32? currentLanguageId)
		{
			return GetAllNewsCategory(null, start, pageLength , newsType, languageId, currentLanguageId);
		}
				
		/// <summary>
		///	This method wrap the '_tblNews_GetAllNewsCategory' stored procedure. 
		/// </summary>
		/// <param name="newsType"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="currentLanguageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public DataSet GetAllNewsCategory(TransactionManager transactionManager, System.String newsType, System.Int32? languageId, System.Int32? currentLanguageId)
		{
			return GetAllNewsCategory(transactionManager, 0, int.MaxValue , newsType, languageId, currentLanguageId);
		}
		
		/// <summary>
		///	This method wrap the '_tblNews_GetAllNewsCategory' stored procedure. 
		/// </summary>
		/// <param name="newsType"> A <c>System.String</c> instance.</param>
		/// <param name="languageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="currentLanguageId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="DataSet"/> instance.</returns>
		public abstract DataSet GetAllNewsCategory(TransactionManager transactionManager, int start, int pageLength , System.String newsType, System.Int32? languageId, System.Int32? currentLanguageId);
		
		#endregion
		
		#region _tblNews_GetNewsBySearch 
		
		/// <summary>
		///	This method wrap the '_tblNews_GetNewsBySearch' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="languageid"> A <c>System.Int32?</c> instance.</param>
		/// <param name="title"> A <c>System.String</c> instance.</param>
		/// <param name="fromdate"> A <c>System.DateTime?</c> instance.</param>
		/// <param name="todate"> A <c>System.DateTime?</c> instance.</param>
		/// <param name="status"> A <c>System.String</c> instance.</param>
		/// <param name="hotNews"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="active"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="itemPerPage"> A <c>System.Int32?</c> instance.</param>
		/// <param name="pageIndex"> A <c>System.Int32?</c> instance.</param>
		/// <param name="newsType"> A <c>System.String</c> instance.</param>
			/// <param name="itemCount"> A <c>System.Int32?</c> instance.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="TList&lt;News&gt;"/> instance.</returns>
		public TList<News> GetNewsBySearch(System.Int32? categoryId, System.Int32? languageid, System.String title, System.DateTime? fromdate, System.DateTime? todate, System.String status, System.Boolean? hotNews, System.Boolean? active, System.Int32? itemPerPage, System.Int32? pageIndex, System.String newsType, ref System.Int32? itemCount)
		{
			return GetNewsBySearch(null, 0, int.MaxValue , categoryId, languageid, title, fromdate, todate, status, hotNews, active, itemPerPage, pageIndex, newsType, ref itemCount);
		}
		
		/// <summary>
		///	This method wrap the '_tblNews_GetNewsBySearch' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="languageid"> A <c>System.Int32?</c> instance.</param>
		/// <param name="title"> A <c>System.String</c> instance.</param>
		/// <param name="fromdate"> A <c>System.DateTime?</c> instance.</param>
		/// <param name="todate"> A <c>System.DateTime?</c> instance.</param>
		/// <param name="status"> A <c>System.String</c> instance.</param>
		/// <param name="hotNews"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="active"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="itemPerPage"> A <c>System.Int32?</c> instance.</param>
		/// <param name="pageIndex"> A <c>System.Int32?</c> instance.</param>
		/// <param name="newsType"> A <c>System.String</c> instance.</param>
			/// <param name="itemCount"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="TList&lt;News&gt;"/> instance.</returns>
		public TList<News> GetNewsBySearch(int start, int pageLength, System.Int32? categoryId, System.Int32? languageid, System.String title, System.DateTime? fromdate, System.DateTime? todate, System.String status, System.Boolean? hotNews, System.Boolean? active, System.Int32? itemPerPage, System.Int32? pageIndex, System.String newsType, ref System.Int32? itemCount)
		{
			return GetNewsBySearch(null, start, pageLength , categoryId, languageid, title, fromdate, todate, status, hotNews, active, itemPerPage, pageIndex, newsType, ref itemCount);
		}
				
		/// <summary>
		///	This method wrap the '_tblNews_GetNewsBySearch' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="languageid"> A <c>System.Int32?</c> instance.</param>
		/// <param name="title"> A <c>System.String</c> instance.</param>
		/// <param name="fromdate"> A <c>System.DateTime?</c> instance.</param>
		/// <param name="todate"> A <c>System.DateTime?</c> instance.</param>
		/// <param name="status"> A <c>System.String</c> instance.</param>
		/// <param name="hotNews"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="active"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="itemPerPage"> A <c>System.Int32?</c> instance.</param>
		/// <param name="pageIndex"> A <c>System.Int32?</c> instance.</param>
		/// <param name="newsType"> A <c>System.String</c> instance.</param>
			/// <param name="itemCount"> A <c>System.Int32?</c> instance.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="TList&lt;News&gt;"/> instance.</returns>
		public TList<News> GetNewsBySearch(TransactionManager transactionManager, System.Int32? categoryId, System.Int32? languageid, System.String title, System.DateTime? fromdate, System.DateTime? todate, System.String status, System.Boolean? hotNews, System.Boolean? active, System.Int32? itemPerPage, System.Int32? pageIndex, System.String newsType, ref System.Int32? itemCount)
		{
			return GetNewsBySearch(transactionManager, 0, int.MaxValue , categoryId, languageid, title, fromdate, todate, status, hotNews, active, itemPerPage, pageIndex, newsType, ref itemCount);
		}
		
		/// <summary>
		///	This method wrap the '_tblNews_GetNewsBySearch' stored procedure. 
		/// </summary>
		/// <param name="categoryId"> A <c>System.Int32?</c> instance.</param>
		/// <param name="languageid"> A <c>System.Int32?</c> instance.</param>
		/// <param name="title"> A <c>System.String</c> instance.</param>
		/// <param name="fromdate"> A <c>System.DateTime?</c> instance.</param>
		/// <param name="todate"> A <c>System.DateTime?</c> instance.</param>
		/// <param name="status"> A <c>System.String</c> instance.</param>
		/// <param name="hotNews"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="active"> A <c>System.Boolean?</c> instance.</param>
		/// <param name="itemPerPage"> A <c>System.Int32?</c> instance.</param>
		/// <param name="pageIndex"> A <c>System.Int32?</c> instance.</param>
		/// <param name="newsType"> A <c>System.String</c> instance.</param>
			/// <param name="itemCount"> A <c>System.Int32?</c> instance.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <remark>This method is generate from a stored procedure.</remark>
		/// <returns>A <see cref="TList&lt;News&gt;"/> instance.</returns>
		public abstract TList<News> GetNewsBySearch(TransactionManager transactionManager, int start, int pageLength , System.Int32? categoryId, System.Int32? languageid, System.String title, System.DateTime? fromdate, System.DateTime? todate, System.String status, System.Boolean? hotNews, System.Boolean? active, System.Int32? itemPerPage, System.Int32? pageIndex, System.String newsType, ref System.Int32? itemCount);
		
		#endregion
		
		#endregion

		#region Helper Functions	
		
		/// <summary>
		/// Fill a TList&lt;News&gt; From a DataReader.
		/// </summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">number of rows.</param>
		/// <returns>a <see cref="TList&lt;News&gt;"/></returns>
		public static TList<News> Fill(IDataReader reader, TList<News> rows, int start, int pageLength)
		{
			NetTiersProvider currentProvider = DataRepository.Provider;
            bool useEntityFactory = currentProvider.UseEntityFactory;
            bool enableEntityTracking = currentProvider.EnableEntityTracking;
            LoadPolicy currentLoadPolicy = currentProvider.CurrentLoadPolicy;
			Type entityCreationFactoryType = currentProvider.EntityCreationalFactoryType;
			
			// advance to the starting row
			for (int i = 0; i < start; i++)
			{
				if (!reader.Read())
				return rows; // not enough rows, just return
			}
			for (int i = 0; i < pageLength; i++)
			{
				if (!reader.Read())
					break; // we are done
					
				string key = null;
				
				ITViet.Domains.News c = null;
				if (useEntityFactory)
				{
					key = new System.Text.StringBuilder("News")
					.Append("|").Append((System.Int32)reader[((int)NewsColumn.Id - 1)]).ToString();
					c = EntityManager.LocateOrCreate<News>(
					key.ToString(), // EntityTrackingKey
					"News",  //Creational Type
					entityCreationFactoryType,  //Factory used to create entity
					enableEntityTracking); // Track this entity?
				}
				else
				{
					c = new ITViet.Domains.News();
				}
				
				if (!enableEntityTracking ||
					c.EntityState == EntityState.Added ||
					(enableEntityTracking &&
					
						(
							(currentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
							(currentLoadPolicy == LoadPolicy.DiscardChanges && c.EntityState != EntityState.Unchanged)
						)
					))
				{
					c.SuppressEntityEvents = true;
					c.Id = (System.Int32)reader[((int)NewsColumn.Id - 1)];
					c.CategoryId = (System.Int32)reader[((int)NewsColumn.CategoryId - 1)];
					c.Code = (System.String)reader[((int)NewsColumn.Code - 1)];
					c.Title = (System.String)reader[((int)NewsColumn.Title - 1)];
					c.ImagePath = (reader.IsDBNull(((int)NewsColumn.ImagePath - 1)))?null:(System.String)reader[((int)NewsColumn.ImagePath - 1)];
					c.Summary = (reader.IsDBNull(((int)NewsColumn.Summary - 1)))?null:(System.String)reader[((int)NewsColumn.Summary - 1)];
					c.Content = (System.String)reader[((int)NewsColumn.Content - 1)];
					c.PostDate = (reader.IsDBNull(((int)NewsColumn.PostDate - 1)))?null:(System.DateTime?)reader[((int)NewsColumn.PostDate - 1)];
					c.Source = (reader.IsDBNull(((int)NewsColumn.Source - 1)))?null:(System.String)reader[((int)NewsColumn.Source - 1)];
					c.CreatedDate = (reader.IsDBNull(((int)NewsColumn.CreatedDate - 1)))?null:(System.DateTime?)reader[((int)NewsColumn.CreatedDate - 1)];
					c.CreatedBy = (reader.IsDBNull(((int)NewsColumn.CreatedBy - 1)))?null:(System.String)reader[((int)NewsColumn.CreatedBy - 1)];
					c.ModifiedDate = (reader.IsDBNull(((int)NewsColumn.ModifiedDate - 1)))?null:(System.DateTime?)reader[((int)NewsColumn.ModifiedDate - 1)];
					c.ModifiedBy = (reader.IsDBNull(((int)NewsColumn.ModifiedBy - 1)))?null:(System.String)reader[((int)NewsColumn.ModifiedBy - 1)];
					c.ApprovedDate = (reader.IsDBNull(((int)NewsColumn.ApprovedDate - 1)))?null:(System.DateTime?)reader[((int)NewsColumn.ApprovedDate - 1)];
					c.ApprovedBy = (reader.IsDBNull(((int)NewsColumn.ApprovedBy - 1)))?null:(System.String)reader[((int)NewsColumn.ApprovedBy - 1)];
					c.IsHotNews = (reader.IsDBNull(((int)NewsColumn.IsHotNews - 1)))?null:(System.Boolean?)reader[((int)NewsColumn.IsHotNews - 1)];
					c.IsActive = (reader.IsDBNull(((int)NewsColumn.IsActive - 1)))?null:(System.Boolean?)reader[((int)NewsColumn.IsActive - 1)];
					c.Status = (reader.IsDBNull(((int)NewsColumn.Status - 1)))?null:(System.String)reader[((int)NewsColumn.Status - 1)];
					c.ViewCount = (reader.IsDBNull(((int)NewsColumn.ViewCount - 1)))?null:(System.Int32?)reader[((int)NewsColumn.ViewCount - 1)];
					c.Tags = (reader.IsDBNull(((int)NewsColumn.Tags - 1)))?null:(System.String)reader[((int)NewsColumn.Tags - 1)];
					c.Type = (reader.IsDBNull(((int)NewsColumn.Type - 1)))?null:(System.String)reader[((int)NewsColumn.Type - 1)];
					c.EntityTrackingKey = key;
					c.AcceptChanges();
					c.SuppressEntityEvents = false;
				}
				rows.Add(c);
			}
		return rows;
		}		
		/// <summary>
		/// Refreshes the <see cref="ITViet.Domains.News"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="ITViet.Domains.News"/> object to refresh.</param>
		public static void RefreshEntity(IDataReader reader, ITViet.Domains.News entity)
		{
			if (!reader.Read()) return;
			
			entity.Id = (System.Int32)reader[((int)NewsColumn.Id - 1)];
			entity.CategoryId = (System.Int32)reader[((int)NewsColumn.CategoryId - 1)];
			entity.Code = (System.String)reader[((int)NewsColumn.Code - 1)];
			entity.Title = (System.String)reader[((int)NewsColumn.Title - 1)];
			entity.ImagePath = (reader.IsDBNull(((int)NewsColumn.ImagePath - 1)))?null:(System.String)reader[((int)NewsColumn.ImagePath - 1)];
			entity.Summary = (reader.IsDBNull(((int)NewsColumn.Summary - 1)))?null:(System.String)reader[((int)NewsColumn.Summary - 1)];
			entity.Content = (System.String)reader[((int)NewsColumn.Content - 1)];
			entity.PostDate = (reader.IsDBNull(((int)NewsColumn.PostDate - 1)))?null:(System.DateTime?)reader[((int)NewsColumn.PostDate - 1)];
			entity.Source = (reader.IsDBNull(((int)NewsColumn.Source - 1)))?null:(System.String)reader[((int)NewsColumn.Source - 1)];
			entity.CreatedDate = (reader.IsDBNull(((int)NewsColumn.CreatedDate - 1)))?null:(System.DateTime?)reader[((int)NewsColumn.CreatedDate - 1)];
			entity.CreatedBy = (reader.IsDBNull(((int)NewsColumn.CreatedBy - 1)))?null:(System.String)reader[((int)NewsColumn.CreatedBy - 1)];
			entity.ModifiedDate = (reader.IsDBNull(((int)NewsColumn.ModifiedDate - 1)))?null:(System.DateTime?)reader[((int)NewsColumn.ModifiedDate - 1)];
			entity.ModifiedBy = (reader.IsDBNull(((int)NewsColumn.ModifiedBy - 1)))?null:(System.String)reader[((int)NewsColumn.ModifiedBy - 1)];
			entity.ApprovedDate = (reader.IsDBNull(((int)NewsColumn.ApprovedDate - 1)))?null:(System.DateTime?)reader[((int)NewsColumn.ApprovedDate - 1)];
			entity.ApprovedBy = (reader.IsDBNull(((int)NewsColumn.ApprovedBy - 1)))?null:(System.String)reader[((int)NewsColumn.ApprovedBy - 1)];
			entity.IsHotNews = (reader.IsDBNull(((int)NewsColumn.IsHotNews - 1)))?null:(System.Boolean?)reader[((int)NewsColumn.IsHotNews - 1)];
			entity.IsActive = (reader.IsDBNull(((int)NewsColumn.IsActive - 1)))?null:(System.Boolean?)reader[((int)NewsColumn.IsActive - 1)];
			entity.Status = (reader.IsDBNull(((int)NewsColumn.Status - 1)))?null:(System.String)reader[((int)NewsColumn.Status - 1)];
			entity.ViewCount = (reader.IsDBNull(((int)NewsColumn.ViewCount - 1)))?null:(System.Int32?)reader[((int)NewsColumn.ViewCount - 1)];
			entity.Tags = (reader.IsDBNull(((int)NewsColumn.Tags - 1)))?null:(System.String)reader[((int)NewsColumn.Tags - 1)];
			entity.Type = (reader.IsDBNull(((int)NewsColumn.Type - 1)))?null:(System.String)reader[((int)NewsColumn.Type - 1)];
			entity.AcceptChanges();
		}
		
		/// <summary>
		/// Refreshes the <see cref="ITViet.Domains.News"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="ITViet.Domains.News"/> object.</param>
		public static void RefreshEntity(DataSet dataSet, ITViet.Domains.News entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.Id = (System.Int32)dataRow["Id"];
			entity.CategoryId = (System.Int32)dataRow["CategoryId"];
			entity.Code = (System.String)dataRow["Code"];
			entity.Title = (System.String)dataRow["Title"];
			entity.ImagePath = Convert.IsDBNull(dataRow["ImagePath"]) ? null : (System.String)dataRow["ImagePath"];
			entity.Summary = Convert.IsDBNull(dataRow["Summary"]) ? null : (System.String)dataRow["Summary"];
			entity.Content = (System.String)dataRow["Content"];
			entity.PostDate = Convert.IsDBNull(dataRow["PostDate"]) ? null : (System.DateTime?)dataRow["PostDate"];
			entity.Source = Convert.IsDBNull(dataRow["Source"]) ? null : (System.String)dataRow["Source"];
			entity.CreatedDate = Convert.IsDBNull(dataRow["CreatedDate"]) ? null : (System.DateTime?)dataRow["CreatedDate"];
			entity.CreatedBy = Convert.IsDBNull(dataRow["CreatedBy"]) ? null : (System.String)dataRow["CreatedBy"];
			entity.ModifiedDate = Convert.IsDBNull(dataRow["ModifiedDate"]) ? null : (System.DateTime?)dataRow["ModifiedDate"];
			entity.ModifiedBy = Convert.IsDBNull(dataRow["ModifiedBy"]) ? null : (System.String)dataRow["ModifiedBy"];
			entity.ApprovedDate = Convert.IsDBNull(dataRow["ApprovedDate"]) ? null : (System.DateTime?)dataRow["ApprovedDate"];
			entity.ApprovedBy = Convert.IsDBNull(dataRow["ApprovedBy"]) ? null : (System.String)dataRow["ApprovedBy"];
			entity.IsHotNews = Convert.IsDBNull(dataRow["IsHotNews"]) ? null : (System.Boolean?)dataRow["IsHotNews"];
			entity.IsActive = Convert.IsDBNull(dataRow["IsActive"]) ? null : (System.Boolean?)dataRow["IsActive"];
			entity.Status = Convert.IsDBNull(dataRow["Status"]) ? null : (System.String)dataRow["Status"];
			entity.ViewCount = Convert.IsDBNull(dataRow["ViewCount"]) ? null : (System.Int32?)dataRow["ViewCount"];
			entity.Tags = Convert.IsDBNull(dataRow["Tags"]) ? null : (System.String)dataRow["Tags"];
			entity.Type = Convert.IsDBNull(dataRow["Type"]) ? null : (System.String)dataRow["Type"];
			entity.AcceptChanges();
		}
		#endregion 
		
		#region DeepLoad Methods
		/// <summary>
		/// Deep Loads the <see cref="IEntity"/> object with criteria based of the child 
		/// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
		/// </summary>
		/// <remarks>
		/// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
		/// </remarks>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">The <see cref="ITViet.Domains.News"/> object to load.</param>
		/// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
		/// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
		/// <param name="childTypes">ITViet.Domains.News Property Collection Type Array To Include or Exclude from Load</param>
		/// <param name="innerList">A collection of child types for easy access.</param>
	    /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
	    /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
		public override void DeepLoad(TransactionManager transactionManager, ITViet.Domains.News entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
		{
			if(entity == null)
				return;

			#region CategoryIdSource	
			if (CanDeepLoad(entity, "NewsCategory|CategoryIdSource", deepLoadType, innerList) 
				&& entity.CategoryIdSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.CategoryId;
				NewsCategory tmpEntity = EntityManager.LocateEntity<NewsCategory>(EntityLocator.ConstructKeyFromPkItems(typeof(NewsCategory), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.CategoryIdSource = tmpEntity;
				else
					entity.CategoryIdSource = DataRepository.NewsCategoryProvider.GetById(transactionManager, entity.CategoryId);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'CategoryIdSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.CategoryIdSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.NewsCategoryProvider.DeepLoad(transactionManager, entity.CategoryIdSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion CategoryIdSource
			
			//used to hold DeepLoad method delegates and fire after all the local children have been loaded.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			
			//Fire all DeepLoad Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			deepHandles = null;
		}
		
		#endregion 
		
		#region DeepSave Methods

		/// <summary>
		/// Deep Save the entire object graph of the ITViet.Domains.News object with criteria based of the child 
		/// Type property array and DeepSaveType.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entity">ITViet.Domains.News instance</param>
		/// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param>
		/// <param name="childTypes">ITViet.Domains.News Property Collection Type Array To Include or Exclude from Save</param>
		/// <param name="innerList">A Hashtable of child types for easy access.</param>
		public override bool DeepSave(TransactionManager transactionManager, ITViet.Domains.News entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList)
		{	
			if (entity == null)
				return false;
							
			#region Composite Parent Properties
			//Save Source Composite Properties, however, don't call deep save on them.  
			//So they only get saved a single level deep.
			
			#region CategoryIdSource
			if (CanDeepSave(entity, "NewsCategory|CategoryIdSource", deepSaveType, innerList) 
				&& entity.CategoryIdSource != null)
			{
				DataRepository.NewsCategoryProvider.Save(transactionManager, entity.CategoryIdSource);
				entity.CategoryId = entity.CategoryIdSource.Id;
			}
			#endregion 
			#endregion Composite Parent Properties

			// Save Root Entity through Provider
			if (!entity.IsDeleted)
				this.Save(transactionManager, entity);
			
			//used to hold DeepSave method delegates and fire after all the local children have been saved.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			//Fire all DeepSave Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			
			// Save Root Entity through Provider, if not already saved in delete mode
			if (entity.IsDeleted)
				this.Save(transactionManager, entity);
				

			deepHandles = null;
						
			return true;
		}
		#endregion
	} // end class
	
	#region NewsChildEntityTypes
	
	///<summary>
	/// Enumeration used to expose the different child entity types 
	/// for child properties in <c>ITViet.Domains.News</c>
	///</summary>
	public enum NewsChildEntityTypes
	{
		
		///<summary>
		/// Composite Property for <c>NewsCategory</c> at CategoryIdSource
		///</summary>
		[ChildEntityType(typeof(NewsCategory))]
		NewsCategory,
		}
	
	#endregion NewsChildEntityTypes
	
	#region NewsFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;NewsColumn&gt;"/> class
	/// that is used exclusively with a <see cref="News"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class NewsFilterBuilder : SqlFilterBuilder<NewsColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the NewsFilterBuilder class.
		/// </summary>
		public NewsFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the NewsFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public NewsFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the NewsFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public NewsFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion NewsFilterBuilder
	
	#region NewsParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;NewsColumn&gt;"/> class
	/// that is used exclusively with a <see cref="News"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class NewsParameterBuilder : ParameterizedSqlFilterBuilder<NewsColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the NewsParameterBuilder class.
		/// </summary>
		public NewsParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the NewsParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public NewsParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the NewsParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public NewsParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion NewsParameterBuilder
	
	#region NewsSortBuilder
    
    /// <summary>
    /// A strongly-typed instance of the <see cref="SqlSortBuilder&lt;NewsColumn&gt;"/> class
	/// that is used exclusively with a <see cref="News"/> object.
    /// </summary>
    [CLSCompliant(true)]
    public class NewsSortBuilder : SqlSortBuilder<NewsColumn>
    {
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the NewsSqlSortBuilder class.
		/// </summary>
		public NewsSortBuilder() : base() { }

		#endregion Constructors

    }    
    #endregion NewsSortBuilder
	
} // end namespace
